import { _decorator, Component, Node, Label, Button } from 'cc';
import { BasePanel } from '../../../../scripts/libs/ui/BasePanel';
import { ReactiveProperty } from '../../../../scripts/libs/rxjs/cc3/ReactiveProperty';
import { BindButton } from '../../../../scripts/libs/rxjs/cc3/BindButton';
const { ccclass, property } = _decorator;

@ccclass('EditorConfirmDialogPanel')
export class EditorConfirmDialogPanel extends BasePanel {

    @property(Label)
    titleLabel: Label = null;

    @property(Label)
    contentLabel: Label = null;

    @property(Button)
    noButton: Button = null;

    @property(Button)
    yesButton: Button = null;

    title = ReactiveProperty.Create('Dialog');
    content = ReactiveProperty.Create('-');

    useObserves() {
        return [
            this.title.subscribe(_ => {
                this.titleLabel.string = _;
            }),
            this.content.subscribe(_ => {
                this.contentLabel.string = _;
            }),
            BindButton(this.noButton).subscribe(this.noButtonClicked.bind(this)),
            BindButton(this.yesButton).subscribe(this.yesButtonClicked.bind(this)),
        ];
    }

    noButtonClicked() {
        EditorConfirmDialogPanel.CloseProcess(null, 'no');
    }

    yesButtonClicked() {
        EditorConfirmDialogPanel.CloseProcess(null, 'yes');
    }

}


